/**
 * 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * 
 */
package org.jiopi.blueprint.mailsender;

import java.io.File;
import java.net.URL;

import org.jiopi.framework.annotation.blueprint.RegisterControlPanel;

/**
 * 
 * a Mail
 * 
 * It should be a prototype
 * 
 * @version 0.1 2010.6.13
 * @since 0.1 2010.6.13
 * @author netstarry
 *
 */
@Version
@RegisterControlPanel("jiopi.Mail")
public interface Mail {
	
	/**
	 * define the mail type
	 */
	public final int TEXT_MAIL = 1;
	public final int HTML_MAIL = 2;
	
	/**
	 * to Receiver, or receivers of the mail. must comply with RFC 2822
	 * @param to
	 */
	public void addTo(String to);
	
	/**
	 * to Receiver
	 * @param email email address
	 * @param name  user name
	 */
	public void addTo(String email,String name);
	
	/**
	 * mail from ,must comply with RFC 2822
	 * @param from
	 */
	public void setFrom(String from);
	
	/**
	 * mail from
	 * @param email email address
	 * @param name  user name
	 */
	public void setFrom(String email,String name);
	
	/**
	 * Set the email subject.
	 * @param subject
	 */
	public void setSubject(String subject);
	
	/**
	 * Define the text content of the mail.
	 * 
	 * @param text
	 */
	public void setTextMsg(String text);
	
	/**
	 * Define the html content of the mail.
	 * 
	 * @param text
	 */
	public void setHtmlMsg(String html);
	
	/**
	 * 
	 * change the Mail Type
	 * 
	 * @param mailType
	 * 
	 * @see Mail#TEXT_MAIL
	 * @see Mail#HTML_MAIL
	 */
	public void changeMailType(int mailType);
	
	/**
	 * Embeds an URL in the HTML.
	 * 
	 * @param url The URL of the file.
	 * @return  A String with the Content-ID of the URL.
	 */
	public String embed(URL url);
	
	/**
	 * Embeds a File in the HTML.
	 * 
	 * @param file The file.
	 * @return  A String with the Content-ID of the URL.
	 */
	public String embed(File file);
	
	/**
	 * Attach an EmailAttachment.
	 * 
	 * @param attachment
	 */
	public void attach(MailAttachment attachment);
	
	/**
	 * Sends the email.
	 * @return the message id of the underlying MimeMessage
	 * @throws SendMailException the sending failed
	 */
	public String send() throws SendMailException;
	
}
